# 1.集合中每个元素的地位都是相同的，元素是无序的
# 2.一个集合中任何两个元素都是不相同的，元素具有唯一性
# 3.给定一个集合和一个元素，这个元素要么属于该集合要么不属于
set1 = {1, 2, 3, 4, 5, 6}
set2 = {"a", "b", "c", "d", "e"}
print(set1)
print(set2)

set3 = set("hello")
print(set3)

set4 = {1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1}
# set4 = set([1,2,3,4,5,6,5,4,3,2,1])
print(set4)

set5 = {num for num in range(0, 20) if num % 3 == 0 or num % 7 == 0}
print(set5)

# 集合的遍历
for i in set2:
    print(i)
# 通过成员运算查看是否存在
print(1 in set1)
print(11 in set1)

# 集合的二元运算
set1 = {1,2,3,4,5,6,7}
set2 = {5,6,7,8,9}
# 交集
print(set1 & set2)
print(set1.intersection(set2))
# 并集
print(set1 | set2)
print(set1.union(set2))
# 差集
print(set1 - set2)
print(set1.difference(set2))
# 对称差
print(set1 ^ set2)
print(set1.symmetric_difference(set2))